package com.gem.sms.util;

import java.util.List;

import lombok.Data;

@Data
public class PageBean<T> {
	// 属性
	private List<T> datas;// 数据
	private int pageNow;// 当前页
	private int pageSize;// 每页显示多少行
	private long total;// 总记录数
	private long pages;// 总页数
	private boolean hasNext;
	private boolean hasPrevious;

	public PageBean(List<T> datas, int pageNow, int pageSize, long total) {
		this.datas = datas;
		this.pageNow = pageNow;
		this.pageSize = pageSize;
		this.total = total;
		this.pages = total % pageSize == 0 ? total / pageSize : total / pageSize + 1;
		if (pageNow == pages) {
			this.hasNext = false;
		} else {
			this.hasNext = true;
		}
		if (pageNow == 1) {
			this.hasPrevious = false;
		} else {
			this.hasPrevious = true;
		}
	}
}
